package org.example.leetcpde;

public interface IListNode {

    public class ListNode implements IArray {
        public int val;
        public ListNode next;

        public ListNode() {
        }

        public ListNode(int val) {
            this.val = val;
        }

        public ListNode(int val,
                 ListNode next) {
            this.val = val;
            this.next = next;
        }

        @Override
        public String toString() {
            StringBuilder builder = new StringBuilder();
            builder.append("cur: " + this.val);
            return builder.toString();
        }

        public ListNode fill(String text) {
            int[] nums = parse(text);
            ListNode former = this;
            this.val = nums[0];
            for (int i = 1; i < nums.length; i++) {
                ListNode node = new ListNode(nums[i]);
                former.next = node;
                former = node;
            }

            return this;
        }
    }
}
